package passworks;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class CommandLineTools {

    private CommandLineTools () {}

    private static BufferedWriter myFile;
    public static String FilePath = "";

    public static String GetParam(String line, int id) {
        /*
         * Ha van egyaltalan parameter, visszaadja azt
         */
        if (line.split(" ").length > id) {
            return line.split(" ")[id];
        }
        return "";
    }

    public static void OpenFileStream(String fileName) {
        try{
            myFile = new BufferedWriter(new FileWriter("output/"+fileName+".outact"));
        } catch (IOException e){
            System.err.println("File megnyitasi hiba");
        }
    }

    public static void WriteToStream(String line) {
        try{
            myFile.write(line + "\n");
        } catch (IOException e) {
            System.err.println("File irasi hiba");
        }
    }

    public static void CloseFileStream() {
        try{
            myFile.close();
        } catch (IOException e){
            System.err.println("File bezarasi hiba");
        }
    }
}
